package cn.lyf.myblog.controller.api;

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.node.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static cn.lyf.myblog.controller.api.JsonUtils.*;
import cn.lyf.myblog.mybatis.mappers.*;
import java.util.*;

@RestController
public class FavoritesApi {

    @Autowired
    FavoritesMapper favoritesMapper;

    @RequestMapping("/getFavorites/{uid}")
    JsonNode getFavorites(@PathVariable Integer uid) throws Exception {
        ObjectNode res = mapper.createObjectNode();
        res.put("success", true);
        res.put("code", 200);
        res.put("message", "获取成功！");
        ObjectNode res2 = mapper.createObjectNode();
        res.set("result", res2);
        List<?> l = favoritesMapper.selecFavoritesByUid(uid);
        res2.putPOJO("list", l);
        res2.put("total", l.size());
        return res;
    }
}
